package com.roy.bio;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class BioServer {
	public static void main(String[] args) throws IOException {
		ServerSocket serverSocket = new ServerSocket(8080);
		while (true) {
			Socket socket = serverSocket.accept();
			// 读入请求
			BufferedReader br = new BufferedReader(
					new InputStreamReader(socket.getInputStream()));
			//读取内容，省略
			//br.readLine();

			BufferedWriter bw = new BufferedWriter(
					new OutputStreamWriter(socket.getOutputStream()));

			String outputString = "HTTP/1.1 200 OK\n Content-Type: text/html; charset=UTF-8\n\n"
					+"<html><head><title>bio-demo</title></head><body><h1>BIO--DEMO</h1></body></html>";
			bw.write(outputString);
			bw.flush();

			bw.close();
			br.close();
			socket.close();
		}
	}
}
